package com.wigem.dic.controller;

import com.wigem.dic.entity.DicIndustryEntity;
import com.wigem.dic.service.DicIndustryService;
import com.wigem.dic.vo.DicIndustryVo;
import com.wigem.framework.common.pojo.PageResult;
import com.wigem.framework.common.util.web.response.Result;
import com.wigem.framework.common.util.web.response.ResultController;
import com.wigem.framework.operate.log.core.annotations.OperateLog;
import com.wigem.framework.operate.log.core.enums.OperateTypeEnum;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 行业字典Controller
 *
 * @author ZY
 * @date 2021-10-25
 */
@RestController
@RequestMapping("/eco/industry")
public class DicIndustryController extends ResultController {
    @Resource
    private DicIndustryService dicIndustryService;

    /**
     * 查询行业字典列表
     */
    @ResponseBody
    @GetMapping("/data/list")
    @ApiOperation("查询行业字典列表")
    @OperateLog(name = "查询行业字典列表", type = OperateTypeEnum.GET, module = "查询行业字典列表")
    public Result getList(DicIndustryVo dicIndustryVo) {
        return success(dicIndustryService.getList(dicIndustryVo));
    }

    /**
     * 查询行业字典列表
     */
    @ResponseBody
    @GetMapping("/data/page")
    @ApiOperation("查询行业字典列表")
    @OperateLog(name = "分页查询行业字典列表", type = OperateTypeEnum.GET, module = "分页查询行业字典列表")
    public Result getPageList(DicIndustryVo dicIndustryVo) {
        PageResult<DicIndustryEntity> pageInfo = dicIndustryService.getPageList(dicIndustryVo);
        return success(pageInfo);
    }

    /**
     * 查询行业字典实体
     */
    @ResponseBody
    @GetMapping("/data/entity")
    @ApiOperation("查询行业字典实体")
    @OperateLog(name = "查询行业字典实体", type = OperateTypeEnum.GET, module = "查询行业字典实体")
    public Result getEntity(String keyValue) {
        return success(dicIndustryService.getEntity(keyValue));
    }

    /**
     * 查询行业字典实体
     */
    @ResponseBody
    @GetMapping("/data/{keyValue}")
    @ApiOperation("查询行业字典实体")
    @OperateLog(name = "查询行业字典实体", type = OperateTypeEnum.GET, module = "查询行业字典实体")
    public Result get(@PathVariable String keyValue) {
        return success(dicIndustryService.getEntity(keyValue));
    }

    /**
     * 新增保存
     */
    @ResponseBody
    @PostMapping("/save")
    public Result save(@RequestBody DicIndustryVo dicIndustryVo) {
        dicIndustryService.save(dicIndustryVo);
        return success("保存成功！");
    }


    /**
     * 删除
     */
    @ResponseBody
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") String id) {
        dicIndustryService.delete(id);
        return success("删除成功！");
    }

    /**
     * 移除/逻辑删除
     */
    @ResponseBody
    @DeleteMapping("/remove/{id}")
    public Result remove(@PathVariable("id") String id) {
        dicIndustryService.remove(id);
        return success("删除成功！");
    }
}
